from conversions import conversions

class alu:
        
    def __init__(self):
        self.convert = conversions()    
    
    def compute(self, aluOp, A, B):
        A = self.convert.Convert2ToDecimal(A)
        B = self.convert.Convert2ToDecimal(B)
        if (aluOp == 0b000):
            self.result = A&B
        elif (aluOp == 0b001):
            self.result = A|B
        elif (aluOp == 0b010):
            self.result = self.convert.convertTo2(A+B)
        elif (aluOp == 110):
            self.result = self.convert.convertTo2(A-B)
        elif (aluOp == 111):
            if ( A<B ): #might be reversed, will look up later
                self.result = 1
            else :
                self.result = 0
        else:
            self.result = 0 #add error detection for zero later

    def getResults(self):
        return self.result
    
    def getZero(self):
        if(self.result == 0):
            return 1
        else:
            return 0

#alu = alu()
#alu.compute(0b010,0b001,0b001)
#print(alu.getResults())
